<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MOP</title>
<link href="resource/css/index.css" rel="stylesheet" type="text/css">
<script language="javascript" src="MessageBox.js"></script>
</head>
<script language="javascript">
	self.buttons = new Array();

	function PageLoad()
	{
		var caption = dialogArguments.caption;
		caption = caption == null?"":caption;

		var text = dialogArguments.text;
		text = text == null?"":text;

		var icon = dialogArguments.icon;
		icon = icon == null?"":icon;

		var buttons = dialogArguments.buttons;
		buttons = buttons == null?"": MessageBoxButtons[buttons];

		var defaultButton = dialogArguments.defaultButton;
		defaultButton = defaultButton == null?0:defaultButton;

		var info = dialogArguments.info;

		var infoList = document.getElementById("infoList");

		if(info != null)
		{
			if(typeof(info) == "string")
			{
				info = info.replace(/\n/g,"<br/>");			
				infoList.innerHTML = info;

				if(text==null||text=="")
				{
					text = info;
				}
			}
			else
			{
				if(info.objectList!=null)
				{
					var text = "[" + info.actionName + "]\n";
					text += "成功："+info.successCounts+"记录，失败："+info.failCounts+"记录";
					
					var msg = "";
					for (var i = 0; i < info.objectList.length; i++)
					{	
						msg += "[" + info.actionName + "] ";
						msg += info.objectList[i].modelName + "(" +info.objectList[i].modelCode + ")<br>";
						if(info.objectList[i].failReason != null) msg += info.objectList[i].failReason;
						else msg += "操作成功!";
						msg += "<br>";
					}
					infoList.innerHTML = msg;
				}
				else
				{
					text = info;
				}
			}
		}

		self.document.body.innerHTML = self.document.body.innerHTML
										.replace(/\{\$text\}/g,text)
										.replace(/\{\$icon\}/g,icon)
										.replace(/\{\$buttons\}/g,buttons)
										.replace(/\{\$caption\}/g,caption);
		
		var buttonList = document.getElementById("_buttons").childNodes;

		for (var i = 0; i < buttonList.length; i++)
		{
			if(buttonList[i].className == "bbutton2")
			{
				self.buttons.push(buttonList[i]);
			}
		}

		self.document.body.style.display = "block";
		self.focus();
		self.buttons[defaultButton].focus();
		self.buttons.activeButton = defaultButton;
		if (dialogArguments.buttons == "LogOK" && self.buttons[defaultButton].innerText == "详细信息") {
			self.buttons[defaultButton].click();
		}		

	}
	function KeyUp()
	{
		if(event.keyCode == 27)
			MessageBoxAction.MB_Cancel();
		else if(event.keyCode == 13 && event.srcElement.tagName.toLowerCase()!='textarea')
			self.buttons[self.buttons.activeButton].click();
		else if(event.keyCode == 9)
		{
			self.buttons.activeButton = (++self.buttons.activeButton) % self.buttons.length;
			self.buttons[self.buttons.activeButton].focus();
			return false;
		}
	}
</script>
<body bgcolor="E7E7E7" style="overflow:hidden" onload="PageLoad()" style="display:none" onkeyup="KeyUp()">
<table width="429" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="150" valign="top" background="resource/images/info_fill.gif"><img id="_icon" src="{$icon}" width="150" height="138"></td>
    <td valign="top" background="resource/images/info_fill.gif" style="padding-top:28px;padding-right:10px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td>{$text}</td>
        </tr>
      </table></td>
  </tr>
</table>
<table width="429" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td background="resource/images/info_compart.gif" width="2px"></td>
  </tr>
</table>
<table width="429" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td align="right" bgcolor="E7E7E7" style="padding:10px;">
	<table border="0" cellspacing="0" cellpadding="0">
        <tr id="_buttons">
          {$buttons}
        </tr>
      </table></td>
  </tr>
</table>
 <div align=center id="infoList" style="height:128;width:100%;overflow:auto;border:thin inset;background:#E3E3E3;text-align:left">
 </div>
</body>
</html>
